package cn.jn.lhm.part07;

import java.io.IOException;
import java.nio.channels.Selector;

/**
 * @author lhm 2753914576@qq.com
 * @time 2024/10/17 - 下午9:25
 **/
public abstract class ServerThread extends Thread {

    protected Selector selector;

    public ServerThread(String name) {
        super(name);
        try {
            this.selector = Selector.open();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    protected void closeSelector() {
        try {
            this.selector.close();
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
    }

    protected void wakeupSelector() {
        this.selector.wakeup();
    }
}
